package pe.com.nextel.main;

import com.nextel.ui.OCommandActionListener;
import com.nextel.ui.OCompositeScreen; 
import com.nextel.ui.OSoftKey;
import com.nextel.ui.OUILook; 

public abstract class MVCAction implements OCommandActionListener {

    protected OCompositeScreen formulario;
    protected String titulo;
 
    protected void destroy( ){
//        System.out.println("destroy");
        if(formulario != null){
            //limpia todo el formulario
            formulario.limpiarFormulario = true;
            formulario = null;
            
            System.gc();
        }
    }
    
    public OCompositeScreen showScreen() {
        
        if (formulario == null) {
   
            formulario = new OCompositeScreen(titulo, OUILook.PLAIN_SMALL_TITLE, 2);
   
            formulario.limpiarFormulario = false;
   
            createView();
   
            formulario.setComandListener(this);
            createItems();

        }

        return formulario;
    }

     public OCompositeScreen showScreenOdate() {

        if (formulario == null) {

            formulario = new OCompositeScreen(titulo, OUILook.PLAIN_SMALL_TITLE, 6);

            formulario.limpiarFormulario = false;
            createView();
            formulario.setComandListener(this);
            createItems();

        }
        return formulario;
    }


    protected abstract void createView();

    protected abstract void createItems();

    public abstract void performAction(OSoftKey c);
}

